package arithmetic;

/**
 * 测试java传参 和引用传参
 * @author jiangfeng 2019/7/18 15:42
 */
public class ObectTest {
    public int i = 1;

    public static void main(String[] args) {
       // System.out.println(f10());
        System.out.println(getObject().i);
        System.out.println(testInt());

      /*  int i = 20;
        ObectTest b = new ObectTest();
        b.i = 20;
        new ObectTest().setMethod(b, i);
        System.out.println(b.i);*/
    }

    private void setMethod(ObectTest b,int i){
        i=10;
        b.i=30;
        b = new ObectTest();
        System.out.println(b.i +" "+ i);
    }

    public static String f10() {
        String str = new String("hello");

        try {
            return str;
        } finally {
            str = "imooc";
            System.out.println(str);
            // "imooc";
        }
    }

    public static ObectTest getObject() {
        ObectTest str = new ObectTest();
        str.i=2;
        try {
            return str;
        } finally {
            str=new ObectTest();
            str.i=3;
            // "imooc";
        }
    }

    public static int testInt() {
        //ObectTest str = new ObectTest();
        int i = 10;
        try {
            return i;
        } finally {
           // str=new ObectTest();
            i=30;
            // "imooc";
        }
    }
}
